<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CreateOauthScopesTable extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function up() {
        $table = $this->table('oauth_scopes', ['engine' => 'innodb', 'collation' => 'utf8mb4_unicode_ci', 'comment' => '权限表']);

        $table->addColumn('scope', 'string', ['limit' => 128, 'comment' => '权限名称', 'null' => false]);
        $table->addColumn('is_default', 'boolean', ['signed' => false, 'default' => 0, 'comment' => '是否为默认权限 0:否 1:是']);
        $table->addColumn('created_at', 'datetime', ['comment' => '创建时间', 'null' => false]);
        $table->addColumn('updated_at', 'datetime', ['comment' => '更新时间', 'null' => false]);

        $table->create();
    }

    public function down() {
        $this->table('oauth_scopes')->drop();
    }
}
